/*------------------------------------------------------
                hou_elearningGEN beta v1.0
Author: xtrung.net@gmail.com
Write On: 04/27/2008
Create On:4/13/2012 11:22:58 AM
------------------------------------------------------*/
using hou_elearning.DataAccess.Base;
using hou_elearning.Entity;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
using System.Collections;
using System.Web;

namespace hou_elearning.DataAccess
{    
    public class Cauhoi_DekiemtraDAL : SqlProvider<Cauhoi_DekiemtraEntity>
    {
        static Cauhoi_DekiemtraDAL()
        {
            InitReader();
        }
        protected static void InitReader()
        {
            getFromReader=delegate(SqlDataReader dr)
            {
                Cauhoi_DekiemtraEntity entity = new Cauhoi_DekiemtraEntity();
				entity.FK_iDekiemtraID = Int64.Parse("0"+dr["FK_iDekiemtraID"].ToString());
				entity.FK_iCauhoiID = Int64.Parse("0"+dr["FK_iCauhoiID"].ToString());
                return entity;
            };
        }
        public static Cauhoi_DekiemtraEntity GetOne(Int64 FK_iDekiemtraID)
        {
            string cmdName = "spCauhoi_Dekiemtra_GetByPK";
            SqlParameter p = new SqlParameter("@FK_iDekiemtraID", FK_iDekiemtraID);
            Cauhoi_DekiemtraEntity entity = GetOne(cmdName, p);
            return entity;
        }
        public static List<Cauhoi_DekiemtraEntity> GetAll()
        {
            string cmdName = "spCauhoi_Dekiemtra_Get";
            return GetList(cmdName);
        }
        
        public static int Add(Cauhoi_DekiemtraEntity entity)
        {
            string cmdName = "spCauhoi_Dekiemtra_Insert";
            return Run(cmdName,true,initParams(entity));

        }
        public static bool Edit(Cauhoi_DekiemtraEntity entity)
        {
            string cmdName = "spCauhoi_Dekiemtra_Update";
            return Run(cmdName,false,initParams(entity))>0;
        }
        public static bool Remove(Int64 FK_iDekiemtraID)
        {
            string cmdName = "spCauhoi_Dekiemtra_Delete";
            SqlParameter p = new SqlParameter("@FK_iDekiemtraID", FK_iDekiemtraID);
            return Run(cmdName,false,p)>0;
        }
        public static List<Cauhoi_DekiemtraEntity> GetByFK_iDekiemtraID(Int64 FK_iDekiemtraID)
        {
            string cmdName = "spCauhoi_Dekiemtra_GetByFK_FK_iDekiemtraID";
            SqlParameter p = new SqlParameter("@FK_iDekiemtraID", FK_iDekiemtraID);
            List<Cauhoi_DekiemtraEntity> list = GetList(cmdName, p);
            return list;
        }
     


        #region private
        private static SqlParameter[] initParams(Cauhoi_DekiemtraEntity entity)
        {
            SqlParameter[] p = new SqlParameter[2];
			p[0] = new SqlParameter("@FK_iDekiemtraID", entity.FK_iDekiemtraID);
			p[1] = new SqlParameter("@FK_iCauhoiID", entity.FK_iCauhoiID);
            return p;
        }
        #endregion
       
    }
}